import { _decorator, AudioClip, AudioSource, Component, Node, resources } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('audioControl')
export class audioControl extends Component {

  audioComponent: AudioSource = null
  shotSound: AudioClip = null
  ballSound: AudioClip = null
  manSound1: AudioClip = null
  ikundieSound: AudioClip = null
  jiSound: AudioClip = null


  onLoad() {
    this.audioComponent = this.node.getComponent(AudioSource)
    resources.load('shotSound', AudioClip, (e, audio: AudioClip) => {
      this.shotSound = audio
    })
    resources.load('ballSound', AudioClip, (e, audio: AudioClip) => {
      this.ballSound = audio
    })
    resources.load('manHurt1', AudioClip, (e, audio: AudioClip) => {
      this.manSound1 = audio
    })
    resources.load('ikundieSound', AudioClip, (e, audio: AudioClip) => {
      this.ikundieSound = audio
    })
    resources.load('jiSound', AudioClip, (e, audio: AudioClip) => {
      this.jiSound = audio
    })
  }

  start() {

  }

  update(deltaTime: number) {

  }

  shotVoice() {
    this.audioComponent.playOneShot(this.shotSound, 1)
  }
  ballVoice() {
    this.audioComponent.playOneShot(this.ballSound, 1)
  }
  manVoice() {
    this.audioComponent.playOneShot(this.manSound1, 1)
  }
  ikundieVoice() {
    this.audioComponent.playOneShot(this.ikundieSound, 1)
  }
  jiVoice() {
    this.audioComponent.playOneShot(this.jiSound, 1)
  }
}


